<?php 
require_once('db.php');
$connect = new DatabaseConnection('localhost', 'root', '', 'blogpage');
$db = new selectdb('roniplblog');

	if(isset($_POST['action'])) {

		if ($_POST['action'] == "saveInsert"){
			$value1 = $_POST['value1'];
			$value2 = $_POST['value2'];

			mysql_query("INSERT INTO blogpage(blog_title, blog_content)VALUES('$value1', '$value2')");
			
		}
		elseif ($_POST['action'] == "loadInsert") {
					
			$query = mysql_query("SELECT * FROM blogpage ORDER BY blog_id DESC");

			$returnquery = "";

			while ($row = mysql_fetch_array($query)) {
				$title = $row['blog_title'];
				$content = $row['blog_content'];
				//'<ul><li class="button edit-btn">Edit</li><li class="button del-btn">Delete</li></ul>' .
				$returnquery .= '<div class="rp-blog-wrapper">' .  '<h2 class="rp-blog-title">' . $title . '</h2>' . '<p class="rp-blog-subject">' . $content . '</p>' . '</div>';
			}

			echo $returnquery;
		}elseif ($_POST['action'] == "deleteInsert") {
			$value1 = $_POST['value1'];
			$value2 = $_POST['value2'];

			$query = mysql_query("DELETE FROM blogpage where id='".$_GET['blog_id']. "'");
		}
	}


?>